/**
 * 
 * Copyright (C) 2011 Cody Stoutenburg . All rights reserved.
 *
 *       This program is free software; you can redistribute it and/or
 *       modify it under the terms of the GNU Lesser General Public License
 *       as published by the Free Software Foundation; either version 2.1
 *       of the License, or (at your option) any later version.
 *
 *       This program is distributed in the hope that it will be useful,
 *       but WITHOUT ANY WARRANTY; without even the implied warranty of
 *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *       GNU Lesser General Public License for more details.
 *
 *       You should have received a copy of the GNU Lesser General Public License
 *       along with this program; if not, write to the Free Software
 *       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 * 
 */
package ca.usherbrooke.behaviours.goal.request;

import jade.core.AID;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;

import java.io.IOException;

import ca.usherbrooke.agent.BasicAgent;
import ca.usherbrooke.agent.message.RequestMessageObjectGoal;
import ca.usherbrooke.behaviours.BasicRequestBehaviour;
import ca.usherbrooke.behaviours.goal.GoalResponderBehaviour;

/**
 * @author Cody Stoutenburg
 * 
 */
public class BasicRequestGoal extends BasicRequestBehaviour<BasicAgent> {
	private static final long serialVersionUID = 1L;

	private static final <E extends Agent> ACLMessage generateMessage(E sender,
			AID receiver, RequestMessageObjectGoal<?> goal) {
		ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
		msg.setProtocol(GoalResponderBehaviour.REQUEST_GOAL_PROTOCOL);
		msg.setSender(sender.getAID());
		msg.addReceiver(receiver);
		try {
			msg.setContentObject(goal);
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		return msg;
	}

	/**
	 * @param a
	 * @param msg
	 */
	public BasicRequestGoal(BasicAgent a, AID receiver,
			RequestMessageObjectGoal<?> goal) {
		super(a, generateMessage(a, receiver, goal));
	}

	@Override
	public void messageReceive(ACLMessage resut) {

	}

}
